package com.atguigu03.list.exer1;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import java.util.Scanner;

/**
 * ClassName: test1
 * Package: com.atguigu03.list.exer1
 * Description:
 *
 * @Author BuTang
 * @Create 2023/6/5 16:49
 * @Version 1.0
 */
public class test1 {
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        ArrayList a = new ArrayList();
        System.out.println("请录入学生的信息");

        while (true){
            System.out.println("1:继续录入，0:结束录入");
            int type ;
            String name;
            try {
                type = sca.nextInt();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            if(type == 1){
                System.out.println("请输入学生姓名");
                name = sca.next();
                System.out.println("请输入学生年龄");
                type = sca.nextInt();

                Student student = new Student(name,type);


                a.add(student);
            }
            else break;

        }
        System.out.println("结束录入");
        for (Object obj : a){
            System.out.println(obj);
        }

        sca.close();
    }
}
